package com.foreknow.springboot.threaddemo;

/**
 * @author xiaoming
 * @version jdk1.8
 * @date 2022/8/11 16:21
 * @function:
 */
public class Thread1 implements Runnable {
    @Override
    public void run() {
        synchronized (WaitAndSleep.class){
            System.out.println("enter Thread1.....");
            System.out.println("enter Thread1 is waiting.....");

            try {
                //调用wait方法，线程会放弃对象锁，进入等待此对象的锁定池中
                WaitAndSleep.class.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(" Thread1 is going on.....");
            System.out.println(" Thread1 is over.....");

        }
    }
}
